package com.hb.unic.core.async.impl;

import java.util.LinkedList;
import java.util.List;

import com.hb.unic.core.async.IMessageProcessor;
import com.hb.unic.core.context.Application;

import lombok.Getter;

/**
 * 异步消息配置
 *
 * @since v1.0，2023/8/28 22:54，create by Mr.Huang.
 */
@Getter
public class MessageProcessorConfig {

    /**
     * 消息类型
     */
    private String messageType;

    /**
     * 消息处理器类
     */
    private List<IMessageProcessor> processors;

    public MessageProcessorConfig(String messageType, String... processorBeanNames) {
        this.messageType = messageType;
        if (processorBeanNames != null && processorBeanNames.length > 0) {
            processors = new LinkedList<>();
            for (String processorBeanName : processorBeanNames) {
                processors.add(Application.getContext().getBean(processorBeanName, IMessageProcessor.class));
            }
        }
    }
}
